const BASEURL = "http://123.207.32.32:9001";

class HJRequest {
  request({ url, method = "GET", data = {} }) {
    return new Promise((resolve, reject) => {
      wx.request({
        url: BASEURL + url,
        method: method,
        data,
        success: (res) => {
          resolve(res.data);
        },
        fail: reject,
        // fail: (err) => {
        //   reject(err);
        // },
      });
    });
  }

  get(url, data = {}) {
    return this.request({ url, data });
  }
  post(url, data = {}) {
    return this.request({ url, data, method: "POST" });
  }
}

const request = new HJRequest();

export default request;
